module.exports = app => {
    const { STRING, INTEGER } = app.Sequelize;

    const TopicMaterial = app.model.define('topic-material', {
        topicId: {
            type: INTEGER,
            allowNull: false,
        },
        title: {
            type: STRING(255),
            allowNull: false,
        },
        link: {
            type: STRING(255),
            allowNull: false,
        }
    }, {
        timestamps: true,
        underscored: false,
    });

    TopicMaterial.associate = function () {
        TopicMaterial.Topic = TopicMaterial.belongsTo(app.model.Topic, {
            foreignKey: "topicId",
            as: "topic"
        });
    };


    return TopicMaterial;
};
